// h->ProfileX("_pfx1");  _pfx1->Draw("same"); _pfx1->Fit("pol1");

void tmp(){
  TFile *f = new TFile(getenv("TMP1"), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  TTree *et = (TTree *)f->Get("et");
  etf->AddFriend(et);

	TCanvas *c = new TCanvas("c", "c", 1680, 1050);
	c->SetGrid();
	c->ToggleToolBar();
	c->ToggleEventStatus();
  // etf->Draw("pTAU[1]:pTAU[0]>>(500, -60., 60., 500, -60., 60.)", "", "col");
  // etf->Draw("pTAD[1]:pTAD[0]>>(500, -60., 60., 500, -60., 60.)", "", "col");
  // etf->Draw("pT1[1]:pT1[0]>>(500, -60., 60., 500, -60., 60.)", "", "col");
  // etf->Draw("pdcTaU[0][1]:pdcTaU[0][0]>>(500, -60., 60., 500, -60., 60.)", "", "col");
  // etf->Draw("pdcTaU[1][1]:pdcTaU[1][0]>>(500, -60., 60., 500, -60., 60.)", "", "col");
  // // de[0] correction
  // etf->Draw("music0.dE(0)/1000.:pdcTaU[1][1]>>(500, -60., 60., 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]:pdcTaU[1][0]>>(36, -45., 45., 1000, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]:pdcTaU[1][1]>>(500, -60., 60., 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]:pdcTaU[1][1]>>(500, -60., 60., 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]:beta0>>(500, 0.6, 0.7, 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-3:beta0>>(500, 0.6, 0.7, 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-3:k0[0]>>(500, -0.02, 0.02, 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-3.40955*k0[1]-3:k0[1]>>(500, -0.02, 0.02, 500, 0., 4.2)", "", "col");
  // final corrected dE[0]
  // const char *zm = "(dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-3)>2.5 && (dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-3)<2.6";
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-4.5*k0[1]-3.5*k0[0]-3>>(1000, 0.5, 3.)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+4.47213*beta0-4.5*k0[1]-3.5*k0[0]-3:tof1+0.035*pT1[0]-0.11*x_f1>>(1000, 125, 140., 1000, 0.5, 3.)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]:pdcTaU[1][0]>>(500, -60., 60., 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:pdcTaU[1][0]>>(500, -60., 60., 500, 0., 4.2)", "", "col");
  // etf->Draw("beta0>>(500, 0.3, 0.8)");
  // etf->Draw("tof1>>(500, 120., 160)");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:beta0>>(500, 0.3, 0.8, 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:tof1>>(500, 120., 160., 500, 0., 4.2)", "", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:aoz0>>(500, 1., 3., 500, 0., 4.2)", "", "col");
  // // A0
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]:tof1>>(500, 125., 138., 500, 0., 4.2)", "", "col");
  // // tof1:pT1x: pol1: tof1=-0.00926143*pT1x+131.528; pol2: -0.000136846*pT1x^2-0.0104155*pT1x+131.551
  // etf->Draw("tof1:x_f1>>(52, -52., 52., 100, 128., 136.)", "A0", "col");
  // // x_ETF correction
  // etf->Draw("tof1:pT1[0]>>(300, -40., 40., 100, 128., 136.)", "A0", "col");
  // etf->Draw("tof1+0.0104155*pT1[0]+0.000136846*pT1[0]*pT1[0]:pT1[0]>>(300, -40., 40., 100, 128., 136.)", "A0", "col");
  // // x_F1 correction
  // etf->Draw("tof1+0.0104155*pT1[0]+0.000136846*pT1[0]*pT1[0]:x_f1>>(52, -52., 52., 100, 128., 136.)", "A0", "col");
  // // tof1:x_f1: pol2: 0.00161325*x_f1^2+0.106737*x_f1+132.736
  // etf->Draw("tof1+0.0104155*pT1[0]+0.000136846*pT1[0]*pT1[0]-(0.00161325*x_f1*x_f1+0.106737*x_f1):x_f1>>(52, -52., 52., 100, 128., 136.)", "A0", "col");
  // etf->Draw("tof1+0.0104155*pT1[0]+0.000136846*pT1[0]*pT1[0]-0.11*x_f1:x_f1>>(52, -52., 52., 100, 128., 136.)", "A0", "col");
  // // the pid
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:tof1+0.0104155*pT1[0]+0.000136846*pT1[0]*pT1[0]-0.02*x_f1>>(400, 128., 136., 400, 0., 4.2)", "A0", "col");
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:tof1+0.0430315*dcTaU0X0.GetWireId()>>(400, 128., 136., 400, 0., 4.2)", "", "col");

  // // initial worked ribll2 pid //
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]-1.87799*k0[0]:tof1+0.035*pT1[0]-0.11*x_f1>>(500, 120., 150., 500, 0., 4.2)", "", "col");

  // // k0[0] correction
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]:k0[0]>>(400, -0.1, 0.1, 400, 0., 4.2)", "", "col");
  // // refined riblle pid
  // etf->Draw("dE[0]+0.0045*pdcTaU[1][1]+0.0004*pdcTaU[1][0]-1.87799*k0[0]:tof1+0.035*pT1[0]-0.11*x_f1>>(500, 125., 140., 500, 0.2, 3.5)", "", "colbox")
  // // dE1
  // etf->Draw("dE[1]:et.tof2>>(500, 45., 65., 500, 0., 2.5)", "", "col");
  // etf->Draw("dE[1]:pdcTaU[1][1]>>(500, -40., 40., 500, 0., 2.5)", "", "col");
  // etf->Draw("dE[1]-0.014*et.tof2:et.tof2>>(500, 45., 65., 500, -0.5, 1.6)", "", "col");
  // // related pid0
  // etf->Draw("dE[1]-0.014*et.tof2:tof1+0.035*pT1[0]-0.11*x_f1>>(500, 125., 140., 500, -0.5, 1.5)", "", "colbox");
  etf->Draw("aoz>>(500, 0., 5.)");
  etf->Draw("brho>>(500, 0., 5.)");
} // end main function
